<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>算法</title>
    <link rel="stylesheet" href="../../component/pear/css/pear.css"/>
    <style>
        .layui-card{
            overflow-y: auto!important;
        }
        ::-webkit-scrollbar {
            width: 5px;
            height: 5px;
        }
        ::-webkit-scrollbar-thumb {
            background: #c0c0c0;
            box-shadow: inset 0 0 5px rgba(0,0,0,0);
            border-radius: 5px;
            height: 5px;
        }
        ::-webkit-scrollbar-track {
            background: rgba(0,0,0,0.1);
            box-shadow: inset 0 0 5px rgba(0,0,0,0);
            border-radius: 2px;
        }
    </style>
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox" style="overflow: hidden">
        <div class="layui-card" lay-filter="" style="height: 100%;">
            <input type="hidden" name="cameraNum" id="cameraNum" value="${cameraNum!}">
            @for(item in EventList!){
                <div class="layui-card-header" style="color: #049590 !important; font-size: 16px;">${item.typeName}</div>
                <div class="layui-card-body layui-row">
                    @for(event in item.list){
                    <div class="layui-col-xs4">
                        <input type="checkbox" name="sf" value="${event.algorithm}" ${(event.algorithm!)=='head'?'disabled':''} ${(event.algorithm!)=='head'?'checked':''}   title="${event.eventName}" ${(event.enable!)=='1'?'checked':''} lay-skin="primary" style="font-size: 15px;">
                    </div>
                    @}
                </div>
            @}
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="button" class="pear-btn pear-btn-primary pear-btn-sm" onclick="tj()">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
        </div>
    </div>
</form>

<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
<script>
    layui.use(['table', 'form', 'jquery', 'common', 'select' ], function () {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;

        window.tj=function () {
            let loading = layer.load();
            var operationId = $("#operationId").val();
            var sfId = [];
            var cameraNum = $("#cameraNum").val();
            $('input:checkbox[name="sf"]:checked').each(function () {
                sfId.push($(this).val());
            });
            let added = 0;
            $.ajax({
                url: "${ctxPath}/api/camera/watchControl?sfId="+sfId,
                dataType: 'json',
                data: {
                    add: cameraNum,
                    remove: ""
                },
                type: 'get',
                success: function (result) {
                    console.log(result);
                    if (result && result.code == 0) {
                        if (result.data.ADDED_CAMERA.length > 0) {
                            added = 1;
                            layer.msg("保存成功", {icon: 1, time: 1000}, function () {
                                layer.close(loading);
                                parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            });
                        } else {
                            added = 0;
                            layer.msg("保存失败", {icon: 2, time: 1000}, function () {
                                layer.close(loading);
                                parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            });
                        }
                    } else {
                        added = -1;
                        layer.msg("保存失败", {icon: 2, time: 1000}, function () {
                            layer.close(loading);
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                        });
                    }
                }
            });
        }
    })
</script>
</body>
</html>
